#!/usr/bin/python
# vim: set fileencoding=utf-8:  
import urllib2
from bs4 import BeautifulSoup
import sys
from mailqq import *
#设置你自己的163用户名和密码
username = 'yeaxxx@163.com'
password = 'lsb450321'


def check_lives_sina(keword, qq_mail):
    page = urllib2.urlopen("http://lives.sina.cn/event/?channel=finance&topic=globalnews1?tag=&refreshtime=60&fromsinago=0&vt=4&page=1")
    soup = BeautifulSoup(page)
    for incident in soup.findAll('p',class_="live_list_t"):
        what = incident.contents[0]
        str = what.strip()
        if str.find(keword) != -1:
            str0 = incident.parent.find('div', class_="live_list_time").contents[0].strip();
	    title = str0+' '+str
    	    mail_to_qq(qq_mail, title, title)
            print str0+" "+str

if __name__ == "__main__":
    if len(sys.argv) != 3:
	 print "Usage: findyou.py 关键词 qqnumber888@qq.com"
    else:
	 check_lives_sina(sys.argv[1].decode("utf-8"), sys.argv[2])
